package com.neusoft.service.impl;

import com.neusoft.mapper.BusinessMapper;
import com.neusoft.po.Business;
import com.neusoft.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessServiceImpl implements BusinessService {

	@Value("${learning.maskImg}")
	private boolean mask;

	@Autowired
	private BusinessMapper businessMapper;

	@Override
	public List<Business> listBusinessByOrderTypeId(Integer orderTypeId) {
		List<Business> businessList = businessMapper.listBusinessByOrderTypeId(orderTypeId);
		if(mask){
			for(Business business:businessList){
				business.setBusinessImg("masked");
			}
		}
		return businessList;
	}

	@Override
	public Business getBusinessById(Integer businessId) {
		Business business = businessMapper.getBusinessById(businessId);
		if(mask){
			business.setBusinessImg("masked");
		}
		return business;
	}

	@Override
	public Business getBusinessByOwnerId(String ownerUserId){
		Business business = businessMapper.getBusinessByOwnerId(ownerUserId);
		if(mask){
			business.setBusinessImg("masked");
		}
		return business;
	}
}
